<template>
    <view>
        <view class="container_2">
            <view :class="scrollTop > 85 ? 'header_2_fixed' : 'header_2'">
                按
                <text style="color: blue">{{ jobcate.name }}</text>
                职位共匹配
                <text style="color: red">{{ joblist.length }}个</text>
                职位
            </view>

            <view class="news">
                <!-- parse <template is="ejoblist" v-if="joblist" :data="joblist"/> -->
                <block name="ejoblist"  v-if="joblist">
                    <view class="joblist_2" v-for="(item, index) in joblist" :key="index">
                        <view class="title_2" @tap="toJobDetail" :data-id="item.id">
                            <view class="jobinfo_2">
                                <view class="jobinfoleft_2">
                                    <view class="address_2">
                                        <view class="jobname_2">{{ item.jobtitle }}</view>

                                        <view class="moneyinfo_2">
                                            <block v-if="item.money == 0">面议</block>
                                            <block v-else>{{ item.money }}</block>
                                        </view>
                                        <view class="vprice2"></view>
                                    </view>

                                    <view class="joblable_2">{{ item.areaname }} | {{ item.education }}</view>

                                    <view class="special_2">
                                        <view class="items_2" v-for="(itemSpecial, index1) in item.speciallist" :key="index1">{{ itemSpecial }}</view>

                                        <!--
                                                    <view class="items_2" >月休</view> 
                                                    <view class="items_2" >免费培训</view>
                                                    <view class="items_2" >晋升空间</view>
                                                    <view class="items_2" >综合补贴</view>
                                                       -->
                                    </view>
                                </view>

                                <view class="jobinforight_2">
                                    <view class="fxmoney_2" v-if="item.vprice > 0">
                                        <view style="width: 200rpx; color: #fff">推荐奖300元/人</view>
                                        <view>入职奖100元/人</view>
                                    </view>
                                </view>
                            </view>

                            <view class="detail_2">
                                <view class="info_2">
                                    <view class="companyinfo_2" style="font-size: 0.9rem">
                                        {{ item.companyname }}
                                    </view>
                                    <view class="jobmoney_2">
                                        <view class="time_2">{{ item.updatetime }}</view>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </block>
            </view>
        </view>

        <!-- 加载更多 -->
        <view class="loadmore">
            <text>{{ loadMore }}</text>
        </view>

        <view class="u-tap-btn">
            <button class="u-go-home2" open-type="contact">
                <view class="iconfont fa fa-comments-o"></view>
            </button>
        </view>
    </view>
</template>

<script>
import { Job } from '../../model/job-model.js';
var job = new Job();
export default {
    data() {
        return {
            city: uni.getStorageSync('companyinfo').city,
            isCars: true,

            // 选择车源开关
            isSort: true,

            // 选择排序开关
            isPrice: true,

            // 选择价格开关
            isType: true,

            loadMore: '',
            page: 1,
            isArea: true,
            areaid: 0,
            priceid: 0,
            cateid: 0,
            isPrice: true,
            isCate: true,
            areatitle: '',
            pricetitle: '',
            catetitle: '',
            jobln: 0,
            scrollTop: '',
            joblist: '',

            jobcate: {
                name: ''
            }
        };
    },
    onPageScroll: function (t) {
        console.log(t.scrollTop); //会随着用户下滑页面值变大
        var that = this;
        if (t.scrollTop <= 145) {
            that.isArea = true;
            that.isPrice = true;
            that.isCate = true;
            that.setData({
                isArea: that.isArea,
                isPrice: that.isPrice,
                isCate: that.isCate
            });
        }
        that.setData({
            scrollTop: t.scrollTop
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onShow: function (options) {
        this.onShowClone3389(options);
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {},
    /**
     * 生命周期函数--监听页面显示
     */

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {
        uni.showNavigationBarLoading();
        this.onShowClone3389({});
    },
    /**
     * 页面上拉触底事件的处理函数
     */

    onReachBottom(params) {
        var that = this;
        /*
  that.setData({
    loadMore: '正在加载中...'
  })
   */
        this.page = this.page + 1;
        this.getjoblist();
    },
    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {
        return {
            title: '找工作',
            path: '/pages/findjob/index'
        };
    },
    methods: {
        /**
         * 生命周期函数--监听页面加载
         */
        onShowClone3389: function (options) {
            var that = this;
            uni.setNavigationBarTitle({
                title: '职位匹配'
            });

            /*
           wx.showShareMenu({
            withShareTicket: true,
            menus: ['shareAppMessage', 'shareTimeline']
          })
           var cityinfo = wx.getStorageSync('cityinfo');
           console.log(cityinfo);
          if (cityinfo) {
             wx.setStorageSync('city', cityinfo.name);
            that.setData({
              city: wx.getStorageSync('cityinfo').name
             })
           } else {
            }
           var cityid = wx.getStorageSync('cityinfo').id;
           var latitude =   wx.getStorageSync('latitude');
          var longitude = wx.getStorageSync('longitude');
           var params = { cityid: cityid, page: that.data.page, houseareaid: that.data.areaid, priceid: that.data.priceid, jobcateid: that.data.cateid, latitude: latitude, longitude: longitude,type:0 };
           findjob.getJobListData((data) => {
             console.log(data);
             console.log(data.topjoblist);
             that.setData({
                joblist: data.joblist,
                topjoblist:data.topjoblist,
                jobln:data.joblist.length,
                arealist:data.arealist,
                jobcatelist:data.jobcatelist
          });
           wx.hideNavigationBarLoading(); //完成停止加载
          wx.stopPullDownRefresh();
           },params);
          */

            uni.showShareMenu({
                withShareTicket: true,
                menus: ['shareAppMessage', 'shareTimeline']
            });
            var cityinfo = uni.getStorageSync('cityinfo');
            if (cityinfo) {
                uni.setStorageSync('city', cityinfo.name);
                that.getjoblist();
            } else {
                //获取信息
                qqmapsdk = new QQMapWX({
                    // 必填
                    key: '5D3BZ-J55WF-SFPJJ-NI6PG-YN2ZO-M4BHX'
                });

                uni.getLocation({
                    type: 'gcj02',

                    // 默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标
                    success: function (res) {
                        uni.setStorageSync('latitude', res.latitude);
                        uni.setStorageSync('longitude', res.longitude);
                        qqmapsdk.reverseGeocoder({
                            location: {
                                latitude: res.latitude,
                                longitude: res.longitude
                            },

                            success: function (addressRes) {
                                var address = addressRes.result.address_component.city;
                                var city = address.substr(0, address.length - 1);
                                uni.setStorageSync('city', city);
                                that.getjoblist();
                            }
                        });
                    },

                    fail: function () {
                        that.getjoblist();
                        // fail
                    },

                    complete: function () {}
                });
            }
        },

        toSelectPrice: function () {
            var that = this;
            that.scrollTop = 146;
            that.isPrice = false;
            that.isArea = true;
            that.isCate = true;
            that.setData({
                isPrice: that.isPrice,
                isArea: that.isArea,
                isCate: that.isCate,
                scrollTop: that.scrollTop
            });
        },

        toSelectCate: function () {
            var that = this;
            that.scrollTop = 146;
            that.isCate = false;
            that.isPrice = true;
            that.isArea = true;
            that.setData({
                isPrice: that.isPrice,
                isArea: that.isArea,
                isCate: that.isCate,
                scrollTop: that.scrollTop
            });
        },

        toSelectArea: function () {
            var that = this;
            that.scrollTop = 146;
            that.isArea = false;
            that.isCate = true;
            that.isPrice = true;
            that.setData({
                isPrice: that.isPrice,
                isArea: that.isArea,
                isCate: that.isCate,
                scrollTop: that.scrollTop
            });
        },

        SelectAreaItem: function (e) {
            var that = this;
            that.scrollTop = 16;
            var areaid = e.currentTarget.dataset.id;
            that.areatitle = e.currentTarget.dataset.title;
            that.areaid = areaid;
            that.isArea = true;
            that.setData({
                areaid: that.areaid,
                isArea: that.isArea,
                areatitle: that.areatitle,
                scrollTop: that.scrollTop
            });
            that.getjoblist();
        },

        SelectPriceItem: function (e) {
            var that = this;
            that.scrollTop = 16;
            var priceid = e.currentTarget.dataset.id;
            that.pricetitle = e.currentTarget.dataset.title;
            that.priceid = priceid;
            that.isPrice = true;
            that.setData({
                priceid: that.priceid,
                isPrice: that.isPrice,
                pricetitle: that.pricetitle,
                scrollTop: that.scrollTop
            });
            that.getjoblist();
        },

        SelectCateItem: function (e) {
            var that = this;
            that.scrollTop = 16;
            var cateid = e.currentTarget.dataset.id;
            that.catetitle = e.currentTarget.dataset.title;
            that.cateid = cateid;
            that.isCate = true;
            that.setData({
                cateid: that.cateid,
                isCate: that.isCate,
                catetitle: that.catetitle,
                scrollTop: that.scrollTop
            });
            that.getjoblist();
        },

        toSelectJob: function () {
            var that = this;
            uni.navigateTo({
                url: '/pages/selectjob/index'
            });
        },

        getjoblist: function () {
            var that = this;
            var cityid = uni.getStorageSync('cityinfo').id;
            var latitude = uni.getStorageSync('latitude');
            var longitude = uni.getStorageSync('longitude');
            var params = {
                cityid: cityid,
                page: that.page,
                areaid: that.areaid,
                priceid: that.priceid,
                jobcateid: that.cateid,
                latitude: latitude,
                longitude: longitude
            };
            job.getmatchjoblist((data) => {
                that.setData({
                    joblist: data.joblist,
                    jobcate: data.jobcate
                });
            }, params);
        },

        toJobDetail: function (e) {
            var id = e.currentTarget.dataset.id;
            uni.navigateTo({
                url: '/pages/jobdetail/index?id=' + id
            });
        }
    }
};
</script>
<style>
@import '../templates/css/index_2.css'; /* search */
/**app.wxss**/
page {
    background-size: 100% 100%;
    height: 100%;
    font-size: 32rpx;
    font-family: '微软雅黑', '方正黑体';
    color: #333;
    background: #f5f5f5;
}

.container_2 {
    background-color: #f0f1f5;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.header_2 {
    width: 720rpx;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    padding-top: 30rpx;
    padding-bottom: 30rpx;
    background: #fff;
    padding-left: 20rpx;
}
.header_2_fixed {
    width: 720rpx;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    padding-top: 30rpx;
    padding-bottom: 30rpx;
    background: #fff;
    position: fixed;
    z-index: 100;
    top: 0px;
    padding-left: 20rpx;
}

.city_2 {
    height: 80rpx;
    line-height: 80rpx;
    color: #000000;
    font-size: 0.9rem;
    font-weight: 600;
}
.search_2 {
    width: 500rpx;
    height: 80rpx;
    line-height: 80rpx;
    background: #f0f1f5;
    display: flex;
    flex-direction: row;
    justify-content: center;
    border-radius: 30rpx 30rpx 30rpx 0rpx;
}
.search_2 view {
    color: #a6a6a6;
    font-size: 0.7rem;
    align-self: center;
}
.search_2 icon {
    margin-right: 20rpx;
    margin-top: 18rpx;
}

.selectcars {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    padding: 20rpx;
    font-size: 0.8rem;
    background: #ffffff;
}
.selectcars_fixed {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    padding: 20rpx;
    font-size: 0.8rem;

    z-index: 1112;
    position: fixed;
    top: 120rpx;
    background: #fff;
}

.itemselectcars {
    display: flex;
    flex-direction: row;
    height: 60rpx;
    justify-content: center;
    align-items: center;
    width: 24%;
}

.itemselectcars image {
    width: 15rpx;
    height: 15rpx;
    align-self: center;
    margin-left: 5rpx;
}

.red {
    color: #fd6a36;
}

/* 遮罩层 */
.small_overlay {
    position: fixed;
    width: 100%;
    height: 80%;
    bottom: 0;
    left: 0;
    z-index: 666;
    background-color: rgba(0, 0, 0, 0.5);
}

.loadmore {
    line-height: 35px;
    font-size: 15px;
    text-align: center;
}
.makebutton {
    display: flex;
    width: 100%;
    flex-direction: row;
    justify-content: center;
}
.makebutton button {
    background: #e62129;
    color: #fff;
    width: 260rpx;
    height: 70rpx;
    line-height: 70rpx;
    font-size: 0.7rem;
    align-self: center;
}

.news {
    margin-top: 10rpx;
    width: 100%;
    display: flex;
    flex-direction: column;
}
.news .newstitle {
    width: 100%;
    height: 80rpx;
    line-height: 80rpx;
    margin-left: 20rpx;
    font-size: 0.7rem;
    border-bottom: 1rpx solid #efefef;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-content: center;
}

.news .newstitle view:nth-child(1) {
    height: 40rpx;
    line-height: 40rpx;
    width: 6rpx;
    background: #3274e5;
    align-self: center;
    margin-left: 10rpx;
}
.news .newstitle view:nth-child(2) {
    height: 80rpx;
    line-height: 80rpx;
    width: 150rpx;
    padding-left: 15rpx;
}

.news .newslist {
    display: flex;
    flex-direction: row;
    width: 720rpx;
    margin: 0 auto;
    padding: 20rpx;
    margin-bottom: 20rpx;
    background: #fff;
}

.news .newslist .title {
    width: 100%;
    flex-direction: column;
    display: flex;
    justify-content: space-between;
}

.news .newslist .title .detail {
    padding-left: 2%;
    text-align: left;
    font-size: 0.8rem;
    color: #000;
    display: flex;
    flex-direction: row;
    width: 100%;
}

.news .newslist .title .detail .pic {
    width: 20%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.news .newslist .title .detail .pic image {
    width: 120rpx;
    height: 120rpx;
    align-self: center;
    border-radius: 60rpx;
}
.news .newslist .title .detail .pic text {
    font-size: 10px;
    color: #646464;
}

.footimg {
    width: 40rpx;
    height: 40rpx;
    position: absolute;
    left: 120rpx;
    right: 0;
    top: 80rpx;
}

.news .newslist .title .detail .info {
    width: 75%;
}

.news .newslist .title .detail .info view:nth-child(1) {
    padding-top: 10rpx;
    color: #000;
    font-weight: bold;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    font-size: 15px;
}

.news .newslist .title .detail .info view:nth-child(2) {
    padding-top: 10rpx;
    padding-bottom: 10rpx;
    color: #646464;
    font-size: 12px;
}

.news .newslist .title .detail view:nth-child(3) {
    padding-top: 10rpx;
    padding-right: 10rpx;
}
.news .newslist .title .price {
    width: 28%;
}

.news .newslist .title .price .money {
    color: #d65408;
    font-weight: bold;
    font-size: 0.7rem;
    padding-right: 10rpx;
}

.jobname > text {
    color: #b7b7b7;
}
.jobmoney {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    color: #646464;
    font-size: 13px;
}

.jobmoney text {
    color: #1296db;
    margin-left: 10rpx;
}
.info .time {
    color: #ff4129;
    font-size: 0.7rem;
}

/*begin 案例*/
.case {
    margin-top: 10rpx;
    width: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.case .casetitle {
    width: 100%;
    height: 80rpx;
    line-height: 80rpx;
    margin-left: 20rpx;
    font-size: 0.7rem;
    border-bottom: 1rpx solid #efefef;
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    align-content: center;
}
.case .casetitle view:nth-child(1) {
    height: 40rpx;
    line-height: 40rpx;
    width: 6rpx;
    background: red;
    align-self: center;
}
.case .casetitle view:nth-child(2) {
    height: 80rpx;
    line-height: 80rpx;
    width: 150rpx;
    padding-left: 15rpx;
}
.case .caselist {
    display: flex;
    flex-direction: row;
    width: 100%;
    margin: 0 auto;
    padding-top: 10rpx;
    padding-bottom: 10rpx;
    flex-wrap: wrap;
}
.case .caselist .caseitem {
    width: 50%;
    display: flex;
    flex-direction: column;
    margin-bottom: 20rpx;
}
.case .caselist .caseitem .pic {
    height: 220rpx;
    line-height: 220rpx;
    align-items: center;
    justify-content: center;
    display: flex;
}
.case .caselist .caseitem .pic image {
    width: 320rpx;
    height: 220rpx;
}

.case .caselist .caseitem .title {
    height: 40rpx;
    line-height: 40rpx;
    font-size: 0.7rem;
    padding-top: 10rpx;
    color: #3e3e3e;
    padding-left: 40rpx;
}

.case .content {
    font-size: 0.8rem;
    padding: 20rpx;
    text-indent: 50rpx;
    color: #6a6a6a;
}

.logincompany {
    width: 100%;
    background: #fff;
    height: 500rpx;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.logincompany view:nth-child(1) {
    font-weight: bold;
    font-size: 16px;
    color: #000;
}

.logincompany button {
    background: #07b56d;
    font-size: 14px;
    color: #fff;
    width: 250rpx;
    height: 80rpx;
    border-radius: 15rpx;
    margin-top: 30rpx;
}
.logincompany view:nth-child(3) {
    color: #a2a2a2;
    font-size: 14px;
    margin-top: 30rpx;
}
button::after {
    border: 0;
}
/*end 案例*/
@import 'undefined';
</style>
